Page({
  data: {
    avatarUrl: '',
    nextName: '未知',
    historys: []
  },
  onLoad: function (options) {
    wx.getUserInfo({
      success: (res) => {
        this.setData({
          avatarUrl: res.userInfo.avatarUrl,
          nextName: res.userInfo.nickName
        })
      }
    })
    this.getStorageData();
  },
  goToDetail(e) {
    const { id } = e.currentTarget.dataset;
    wx.navigateTo({
      url: '../movie-detail/movie-detail?id=' + id,
    })
  },
  getStorageData: function () {
    //wx.removeStorageSync('historyData')
    let historys = wx.getStorageSync('historyData');
    if (historys) {
      historys = JSON.parse(historys);
      this.setData({
        historys
      })
    }
  },
  onShow: function () {
    this.getStorageData();
  }
})